<?php
/**
 * mk script file created on 6-giu-2005
 * jaco_at_pixeldump_dot_org
 * simple movieclip
 */

include("sample_utils.php");                      // provides some utils and using mk

$swfFN = "test_mk_movieclip01.swf";               // swf file that we will create


$mad = array();                                   // setup an array
$mad["rotation"] = 89;                            // ... that will contain
$mad["x"] = 0;                                    // placing settings, x
$mad["y"] = 0;                                    // ... y
$mad["width"] = 200;                              // ... width and ...
$mad["height"] = 200;                             // height

$colors = array();                                // create ...
$colors[0] = get_color_array("#FFFF00");          // two colors, yellow ...
$colors[1] = get_color_array("#FF0000");          // ... and red

$sc = new MKShapeContainer();                    // create ...
$sc1 = new MKShapeContainer();                   // two shapes
$sc1->set_itemID(2);                              // assign item id to the last shape
                                                  // the first have item id = 1 by default

$sc1->add_gradient_fill(LINEAR_GRADIENT_FILL,
                        $colors, array(0, 0xff),
                        $mad);                    // add gradient fill
$sc1->add_rect(0, 0, 200, 200);                   // draw a rectangle, it will be the background

$mad["x"] = -50;                                  // setup a new placing settings
$mad["y"] = -50;                                  // ...
$mad["width"] = 100;                              // ...
$mad["height"] = 100;                             // ...
$mad["rotation"] = 0;                             // ...

$sc->add_gradient_fill(RADIAL_GRADIENT_FILL,
                       $colors, array(0, 0xff),
                       $mad);                     // a new gradient fill, for the foreground shape
$coords = get_coords_star(0, 0, 50);              // get star coordinates
$sc->add_mixed_poly($coords);                     // draw star


$mc = new MKmovieclip();                          // create new movieclip
$mc->set_spriteID(3);                             // with its item id
$mc->add_tagData($sc->update_place_tagData(), 1);     // place the star in the first frame of mc

for($i = 4.5, $k = 2; $i < 72; $i += 4.5, $k++){  // rotate by 4.5 degree
	$sc->rotate($i,true);                         // assign rotation
	$mc->add_tagData($sc->update_place_tagData(1), $k); // get binary tag data
}

$s1 = $sc1->update_tagData();                     // get binary tag data from shapes
$s2 = $sc->update_tagData();                      // ..
$mcTagData = $mc->update_tagData();               // get binary tag data from mc

$swf = new MKSwf($swfFN);                        // create new swf
$swf->set_stageWidth(200);                        // setup canvas
$swf->set_stageHeight(200);                       // ...
$swf->set_fps(24);                                // frames per second
$swf->set_swfDir(SERVER_MKTMP);                   // set working directory

$swf->add_tagData($s1);                           // start to populate swf
$swf->add_tagData($s2);                           // ...
$swf->add_tagData($mcTagData);                    // ...

$po = new MKPlaceObject2("", 3, 3);               // new placing settings
$po->set_position(100, 100);                      // ...

$swf->add_tagData($sc1->update_place_tagData());  // ...
$swf->add_tagData($po->update_tagData());         // ...
$swf->swf_output();                               // write to disk

$swfHeader = $swf->fetch_assoc();                 // prepare to publish

$str = render_swf_box($swfHeader, $imgDir, false);
$str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>";
echo show_content($str, basename(__FILE__));
?>
